<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>点击换色</title>
    <style>
        .bg{
            color: red;
        }
        .bgc{
            color: gray;
        }
    </style>
</head>
<body>
    <div id="app">
        <li v-for='(item,index) in stu' :class='{bg: index==isIndex}' @click='add(index)'>{{item}}</li>
    </div>
</body>
<script src="../js/vue.js"></script>
<script>
    let app = new Vue({
        el:'#app',
        data:{
            stu:['海王','皮卡丘','吴浩','小猪佩奇'],
            isIndex:0
        },
        methods:{
            add(index){
                this.isIndex = index
                
            }
        }
    })
</script>
</html>